#include<bits/stdc++.h>
using namespace std;
int a[5000000],d[5000000],mina;

int main(){
	int n,p;
	cin>>n>>p;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		d[i]=a[i]-a[i-1];
	}
	while(p--){
	    int x,y,z;
		cin>>x>>y>>z;
		d[x]+=z;
		d[y+1]-=z;	
	}
	mina=1e9;
	for(int i=1;i<=n;i++){
	    a[i]=a[i-1]+d[i];
		if(mina>a[i]) mina=a[i];	
	}
	cout<<mina;
}